<?php
###############   COPYLEFT GPLv3 LICENSE   ###############
##
## JFX Version 0.2.7
## Website Management Software
## www.jfxcms.com
##
## Copyright 2009 GPLv3 - http://www.opensource.org/licenses/gpl-3.0.html
##
## Anthony Gallon
## oi_antz@hotmail.com
##
## Permission is hereby granted to any person having a copy of this software
## to freely use and modify as required so long as the copyright notices
## and branding remain intact.
##
## Full license details available at http://www.jfxcms.com/license
##
###############   COPYLEFT GPLv3 LICENSE   ###############

while(ob_get_level()>0) ob_end_clean();

unset($requestUri[0]);
$requestUri = array_regenerate_keys($requestUri);
$moduleKey = $requestUri[0];
unset($requestUri[0]);
$filename = implode('/', $requestUri);
$filename = str_replace('../', '', $filename);

if($SETTINGS->get('theme-admin')===$moduleKey){
    $MODULE = JFX::registry('JFX_Theme_'.ucfirst(strtolower($moduleKey)));
}else if($SETTINGS->get('theme-public')===$moduleKey){
    $MODULE = JFX::registry('JFX_Theme_'.ucfirst(strtolower($moduleKey)));
}else{
    $MODULE = JFX::registry('JFX_Module_'.ucfirst(strtolower($moduleKey)));
}

if(!isset($MODULE) || !is_object($MODULE)) exit('Could not instantiate JFX_Module_'.ucfirst(strtolower($moduleKey)));

header('Content-Type: text/javascript');
header('Cache-Control: public');

ob_start();
$MODULE->printJsFile($filename);
$fc = ob_get_contents();
ob_end_clean();


$fc = str_replace($this->ownerLicense, '', $fc);
$fc = str_replace('/**/', '', $fc);
$fc = '/*'.$this->publicLicense."*/\n\n".$fc;

exit($fc);